package com.ruoyi.biz.service.impl;

import java.util.List;

import com.ruoyi.biz.domain.EquipmentInfo;
import com.ruoyi.biz.dto.EquipmentInfoDTO;
import com.ruoyi.biz.mapper.EquipmentInfoMapper;
import com.ruoyi.biz.service.IEquipmentInfoService;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2020-11-30
 */
@Service
public class EquipmentInfoServiceImpl implements IEquipmentInfoService
{
    @Resource
    private EquipmentInfoMapper equipmentInfoMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param equipmentId 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public EquipmentInfo selectEquipmentInfoById(Long equipmentId)
    {
        return equipmentInfoMapper.selectEquipmentInfoById(equipmentId);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param equipmentInfo 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u") // 添加部门表的别名 显示自己部门和自己子部门的数据
    public List<EquipmentInfo> selectEquipmentInfoList(EquipmentInfo equipmentInfo)
    {
        return equipmentInfoMapper.selectEquipmentInfoList(equipmentInfo);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param equipmentInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertEquipmentInfo(EquipmentInfo equipmentInfo)
    {
        equipmentInfo.setCreateTime(DateUtils.getNowDate());
        return equipmentInfoMapper.insertEquipmentInfo(equipmentInfo);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param equipmentInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateEquipmentInfo(EquipmentInfo equipmentInfo)
    {
        equipmentInfo.setUpdateTime(DateUtils.getNowDate());
        return equipmentInfoMapper.updateEquipmentInfo(equipmentInfo);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param equipmentIds 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteEquipmentInfoByIds(Long[] equipmentIds)
    {
        return equipmentInfoMapper.deleteEquipmentInfoByIds(equipmentIds);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param equipmentId 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteEquipmentInfoById(Long equipmentId)
    {
        return equipmentInfoMapper.deleteEquipmentInfoById(equipmentId);
    }

    /**
     * 设备启用和禁用
     * @param equipmentInfo
     * @return
     */
    @Override
    public int startOrStopEquipment(EquipmentInfo equipmentInfo) {
        return equipmentInfoMapper.startOrStopEquipment(equipmentInfo);
    }

    /**
     * 设备的忽略告警和恢复告警
     * @param equipmentInfo
     * @return
     */
    @Override
    public int isIgnoreWarn(EquipmentInfo equipmentInfo) {
        return equipmentInfoMapper.isIgnoreWarn(equipmentInfo);
    }

    @Override
    public List<EquipmentInfo> findEquipmentListByUserId(Long userId) {
        return equipmentInfoMapper.findEquipmentListByUserId(userId);
    }

    /**
     * 查找最大排序
     * @return
     */
    @Override
    public Integer findMaxSort() {
        return equipmentInfoMapper.findMaxSort();
    }

    @Override
    public List<EquipmentInfoDTO> selectEquipmentInfoDTOList(EquipmentInfo equipmentInfo) {
        return equipmentInfoMapper.selectEquipmentInfoDTOList(equipmentInfo);
    }

    @Override
    public List<EquipmentInfoDTO> selectInfoList(EquipmentInfo equipmentInfo) {
        return equipmentInfoMapper.selectInfoList(equipmentInfo);
    }
}
